package com.example.support.oss;

import org.springframework.context.annotation.Bean;

import com.aliyun.oss.OSSClient;

@org.springframework.context.annotation.Configuration
@org.springframework.boot.context.properties.EnableConfigurationProperties(AliOssProperties.class)
public class AliOssConfiguration {

	@Bean(destroyMethod = "shutdown")
	public OSSClient ossClient(AliOssProperties aliOssProperties) {
		OSSClient ossClient = new OSSClient(aliOssProperties.getEndpoint(), aliOssProperties.getAccessKeyId(), aliOssProperties.getAccessKeySecret());
		return ossClient;
	}

	@Bean
	public AliOssClient aliOssClient(OSSClient ossClient, AliOssProperties aliOssProperties) {
		return new AliOssClient(ossClient, aliOssProperties);
	}

}
